﻿using Super_Management_Mayhem.Screens.Playing.Players;
using Transformable_Engine_v2.Engine.Transformable_Math.Geometry;

namespace Super_Management_Mayhem.Screens.Playing.AttackModel
{
    public class RadialAttack : BaseAttack
    {
        private float _velocity;

        public RadialAttack(TargetTeam targetType, Team targetTeam, IAttacker attackerObject, int damage, int hurtTime, TE_Rectangle attackBoundingBox, float velocity) : base(targetType, targetTeam, attackerObject, damage, hurtTime, attackBoundingBox)
        {
            _velocity = velocity;
        }

        public override bool Attack(IAttackable possibleTarget)
        {
            if (IsValidTarget(possibleTarget))
            {
                if (possibleTarget.Hit((possibleTarget.GetPosition() - Attacker.GetPosition()).ToUnit() * _velocity,
                        Attacker.GetPosition(), 
                        HurtTime, 
                        Damage))
                    Attacker.OnAttack();
            }

            return false;
        }

        public override void Attack(TE_Vector2 position)
        {
            Playscreen.Map.Attack(this, AttackBoundingBox + position);
        }
    }
}